#include <bits/stdc++.h>

using namespace std;



struct ListNode {
    int val;
    ListNode *next;
    ListNode(int x) : val(x), next(NULL) {}
};

class Solution {
public:
    ListNode* deleteNode(ListNode* head, int val) {
        if(val==head->val){
            return head->next;
        }
        ListNode *p=head,*q=head;
        while(p->next&&p->val!=val){
            q=p;
            p=p->next;
        }
        if(p->val==val){
            q->next=p->next;
        }
        return head;
    }
};

int main(){




    return 0;
}